package com.itheima.table02;

import com.itheima.bean.Classes;
import com.itheima.bean.Student;
import com.itheima.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Test02 {
    @Test
    public void findAll(){
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        OneToManyMapper mapper = sqlSession.getMapper(OneToManyMapper.class);
        List<Classes> list = mapper.findAll();
        for (Classes classes : list) {
            System.out.println(classes.getId()+","+classes.getName());
            List<Student> students = classes.getStudents();
            for (Student student : students) {
                System.out.println(student);
            }
        }
        sqlSession.close();
    }
}
